package com.huang.aspects;


import com.huang.service.impl.IEmailService;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;

@Component
@Aspect
public class EmailAdvice implements IEmailService {

	@Pointcut("execution(* com.huang.service.crud.ICrudServiceImpl.*(..))")
	public void email(){}

	@Autowired
	private JdbcTemplate jdbcTemplate;
	@Override
	@Before("email()")
	public void addEmailInfo() {
		String sql = "insert into email values (?,?)";
		int update = jdbcTemplate.update(sql, null, "有人在刚刚操作了数据库！");
		System.out.println(update);
	}
}
